home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
science
/
sm32a.zip
/
LIBRARY
/
PSOLVE.LI
< prev
next >
Wrap
Text File
|
1994-09-21
|
827b
|
14 lines
# psolve() is polynomial solver
# e.g. psolve(x^2+5*x+6, x) gives [-2, -3]
psolve(y_, x1_) := if(order(y,x1) == 1,
-coef(y,x1,0)/coef(y,x1,1) )
psolve(y_, x2_) := if(order(y,x2) == 2,
[(-coef(y,x2,1)+sqrt(coef(y,x2,1)^2-4*coef(y,x2,2)*coef(y,x2,0)))/(2*coef(y,x2,2)),
(-coef(y,x2,1)-sqrt(coef(y,x2,1)^2-4*coef(y,x2,2)*coef(y,x2,0)))/(2*coef(y,x2,2))])
psolve(y_, x4_) := if(order(y,x4) == 4 and coef(y,x4,3) ==0 and coef(y,x4,1)==0,
[sqrt((-coef(y,x4,2)+sqrt(coef(y,x4,2)^2-4*coef(y,x4,4)*coef(y,x4,0)))/(2*coef(y,x4,4))),
-sqrt((-coef(y,x4,2)+sqrt(coef(y,x4,2)^2-4*coef(y,x4,4)*coef(y,x4,0)))/(2*coef(y,x4,4))),
sqrt((-coef(y,x4,2)-sqrt(coef(y,x4,2)^2-4*coef(y,x4,4)*coef(y,x4,0)))/(2*coef(y,x4,4))),
-sqrt((-coef(y,x4,2)-sqrt(coef(y,x4,2)^2-4*coef(y,x4,4)*coef(y,x4,0)))/(2*coef(y,x4,4))) ])